package cn.com.headfree.mouldshow.dao.impl;

import cn.com.headfree.entity.TPatentInfoTemp;
import cn.com.headfree.mouldshow.dao.TPatentInfoTempDao;
import com.gta.edu.sdk.base.dao.impl.BaseDaoImpl;
import org.springframework.stereotype.Repository;

import java.sql.Timestamp;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Repository("/tPatentInfoTempDao")
public class TPatentInfoTempDaoImpl extends BaseDaoImpl<TPatentInfoTemp> implements TPatentInfoTempDao {


    @Override
    public void saveInfo(TPatentInfoTemp tPatentInfo) {
        String sql = "insert into t_patent_info_temp (id,patent_name,patent_no,patent_type,apply_date,decl_date,inventor,org_id,creater_id,creater_name,create_time,updater_id,updater_name,update_time,del_sign,is_valid,audit_state,orignal_id,business_type_id,primitive_id) values ";
        StringBuilder sqlBuilder = new StringBuilder(sql);
        sqlBuilder.append("(#{id,jdbcType=VARCHAR},").append("#{patent_name,jdbcType=VARCHAR},")
                .append("#{patent_no,jdbcType=VARCHAR},").append("#{patent_type,jdbcType=VARCHAR},")
                .append("#{apply_date,jdbcType=VARCHAR},").append("#{decl_date,jdbcType=VARCHAR},")
                .append("#{inventor,jdbcType=DATE},").append("#{org_id,jdbcType=DATE},").append("#{creater_id,jdbcType=DATE},")
                .append("#{creater_name,jdbcType=VARCHAR},").append("#{create_time,jdbcType=DATE},")
                .append("#{updater_id,jdbcType=VARCHAR},").append("#{updater_name,jdbcType=VARCHAR},")
                .append("#{update_time,jdbcType=DATE},").append("#{del_sign,jdbcType=INTEGER},")
                .append("#{is_valid,jdbcType=INTEGER},").append("#{audit_state,jdbcType=INTEGER},")
                .append("#{orignal_id,jdbcType=VARCHAR},").append("#{business_type_id,jdbcType=VARCHAR},")
                .append("#{primitive_id,jdbcType=VARCHAR})");
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("id", tPatentInfo.getId());
        params.put("patent_name", tPatentInfo.getPatentName());
        params.put("patent_no", tPatentInfo.getPatentNo());
        params.put("patent_type", tPatentInfo.getPatentType());
        params.put("apply_date", tPatentInfo.getApplyDate());
        params.put("decl_date", tPatentInfo.getDeclDate());
        params.put("inventor", tPatentInfo.getInventor());
        params.put("org_id", tPatentInfo.getOrgId());
        params.put("creater_id", tPatentInfo.getCreaterId());
        params.put("creater_name", tPatentInfo.getCreaterName());
        params.put("create_time", new Timestamp(new Date().getTime()));
        params.put("updater_id", tPatentInfo.getUpdaterId());
        params.put("updater_name", tPatentInfo.getUpdaterName());
        params.put("update_time", new Timestamp(new Date().getTime()));
        params.put("del_sign", 0);
        params.put("is_valid", tPatentInfo.getIsValid());
        params.put("audit_state", tPatentInfo.getAuditState());
        params.put("orignal_id", tPatentInfo.getOrignalId());
        params.put("business_type_id", tPatentInfo.getBusinessTypeId());
        params.put("primitive_id", tPatentInfo.getPrimitiveId());
        this.executeSql(sqlBuilder.toString(), params);
    }
}
